<title>编辑菜单</title>

<div class="layui-card layadmin-header">
    <div class="layui-breadcrumb" lay-filter="breadcrumb">
        <a lay-href="">主页</a>
        <a><cite>菜单管理</cite></a>
        <a><cite>编辑菜单</cite></a>
    </div>
</div>

<div class="layui-form" id="layuiadmin-form-comment" lay-filter="layuiadmin-form-comment">
        <div class="layui-card-body">
            <script type="text/html" template lay-url="/api/admin/menu/info/{{ d.params }}" lay-done="renderMenuEdit(d)"
                    id="JW_MENI_EDIT">
                <div class="layui-form-item">
                <label class="layui-form-label">菜单名字</label>
                <div class="layui-input-block">
                    <input class="layui-input" name="name" autocomplete="off" lay-verify="required|maxLength|menuName"
                           lay-max="20"
                           placeholder="必填(必须是字母、数字、符号'_#$@'，不能包含其他特殊字符)"
                           value="{{d.data.name}}" type="text">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">菜单文本</label>
                <div class="layui-input-block">
                    <input class="layui-input" name="text" autocomplete="off" lay-verify="required|maxLength"
                           lay-max="10"
                           placeholder="必填(用于页面显示)"
                           value="{{d.data.text}}" type="text">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">菜单图标</label>
                <div class="layui-input-block">
                    <input class="layui-input" name="icon" autocomplete="off" lay-verify="maxLength" lay-max="20"
                           value="{{d.data.icon}}" type="text">
                </div>
            </div>

                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <input id="flagCategory" name="flagCategory"
                               lay-filter="flagCategory"
                               {{# if(d.data.flagCategory){ }}
                               checked
                               {{# } }}
                               title="是否为文章类别"
                               type="checkbox" value="1">
                    </div>
                </div>
            <div class="layui-form-item" id="menuUrl" {{# if(d.data.flagCategory){ }}style="display: none"{{# } }}>
                <label class="layui-form-label">菜单url</label>
                <div class="layui-input-block">
                    <input class="layui-input" name="url" autocomplete="off" lay-verify="urlFmt|maxLength" lay-max="200"
                           value="{{d.data.url}}" type="text">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <input id="valid" name="valid"
                           {{# if(d.data.valid){ }}
                           checked
                           {{# } }}
                           title="是否开启"
                           type="checkbox" value="1">
                </div>
            </div>
            </script>

        </div>

    <script type="text/html" template lay-url="/api/admin/request/token/generate"
            lay-data="{pageId: 'M12'}" lay-type="post">
        <input type="hidden" name="subToken" id="subToken" value="{{d.token}}">
    </script>
    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <div class="layui-input-block">
            <input class="layui-btn" style="float: right" id="menu-edit-submit" lay-filter="menu-edit-submit" lay-submit
                   type="button" value="确认">
        </div>
    </div>
</div>
<script>
    function renderMenuEdit() {
        layui.use(['admin', 'form'], function () {
            var form = layui.form;
            form.render();
            form.on('checkbox(flagCategory)', function (data) {
                if ($('#flagCategory').prop('checked')) {
                    $('#menuUrl').hide()
                }else {
                    $('#menuUrl').show()
                }
                form.render();
            });

        })
    }

</script>